package fr.emse.tatiana.commands;

import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbenchWindow;

import fr.emse.tatiana.CorpusNavigationView;
import fr.emse.tatiana.TatianaConstants;
import fr.emse.tatiana.importexport.ExportCorpusWizard;

public class TatianaExportAction extends Action {

	private static TatianaExportAction instance;

	public static TatianaExportAction getInstance() {
		return instance;
	}

	private IWorkbenchWindow window;
	
	public TatianaExportAction(IWorkbenchWindow window,String label) {
		setText(label);
		this.window = window;
		// The id is used to refer to the action in a menu or toolbar
		setId(ICommandIds.CMD_TATIANA_EXPORT);
		// Associate the action with a pre-defined command, to allow key bindings.
		//setActionDefinitionId(ICommandIds.CMD_FILTER);
		setImageDescriptor(fr.emse.tatiana.Activator.getImageDescriptor("/icons/export_wiz.gif"));
		instance = this;
	}

	public void run() {
		if(window != null) {
			ExportCorpusWizard wizard = new ExportCorpusWizard();
			wizard.init(window.getWorkbench(), ResourcesPlugin.getWorkspace().getRoot().getProject(TatianaConstants.TATIANA_PROJECT_NAME));
			WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
			dialog.create();
			dialog.open();
		}
	}
}
